package vesion2.object;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.awt.*;

/**
 * 游戏所有物体的抽象
 */
public abstract class GameObject {
    //物体是否存活（是否绘制）
    @JsonIgnore
    protected volatile boolean isAlive;
    //背景色
    @JsonIgnore
    protected Color backColor;
    //图片
    @JsonIgnore
    protected Image image;

    public GameObject(){
        this(null,null);
    }

    public GameObject(Color backColor,Image image)
    {
        this.backColor=backColor;
        this.image=image;
        isAlive=true;
    }

    @JsonIgnore
    public boolean isAlive() {
        return isAlive;
    }
    @JsonIgnore
    public void setAlive(boolean alive) {
        isAlive = alive;
    }

    public Color getBackColor() {
        return backColor;
    }

    public void setBackColor(Color backColor) {
        this.backColor = backColor;
    }

    public Image getImage() {
        return image;
    }

    public void setImage(Image image) {
        this.image = image;
    }

    public abstract void draw(Graphics g);

    public abstract boolean isIntersect(GameObject object);
}
